///=================================================================================================
/// COPYRIGHT MorningCoreTech CO.,LTD
/// @file        SRP_Top_PUCCH_fix.cpp
/// @brief       This function performs PUCCH Top Proc
/// @author	cuiyuping
/// @date	2022/10/25
/// @param [IN]	     SimParam		       Input  Parameter .
/// @param [OUT]	  BRP_UCI_Op		    bit data.
/// @param [OUT]	 SubFrame_FD_Buffer		
/// @par History 
/// -
///       Date|       Author|        Version|        DESCRIPTION
/// ----------|-------------|---------------|-------------------
/// 2022-10-25|    cuiyuping|          0.0.1|            created
///=================================================================================================

#include "stdlib.h"
#include "ue_tx_pucch_top_fix.h"


void SRP_Top_PUCCH_fix(
	IN stULParamTable *SimParam, 
	IN       int8     *BRP_UCI_Op,
	OUT cmplx_frN  *SubFrame_FD_Buffer[MAXSYMNUM])
{
  //===========variable declaration ==========//
	int iSym;
  cmplx_frN *PUCCH_DMRS_Ip[PUCCH_DMRS_MAX_NUM]; 
  cmplx_frN *PUCCH_ZC_Data[PUCCH_DATA_MAX_NUM];

  for (iSym = 0; iSym < PUCCH_DMRS_MAX_NUM; iSym++)
  {
	  PUCCH_DMRS_Ip[iSym] = (cmplx_frN *)malloc((PUCCH_Max_RE) * sizeof(cmplx_frN));
	  memset(PUCCH_DMRS_Ip[iSym], 0, (PUCCH_Max_RE) * sizeof(cmplx_frN));
  }
  for (iSym = 0; iSym < PUCCH_DATA_MAX_NUM; iSym++)
  {
	  PUCCH_ZC_Data[iSym] = (cmplx_frN *)malloc((PUCCH_Max_RE) * sizeof(cmplx_frN));
	  memset(PUCCH_ZC_Data[iSym], 0, (PUCCH_Max_RE) * sizeof(cmplx_frN));
  }

    //=======================DMRS Gernaration ============================//
  PUCCH_DmrsSeq_Gen_fix(SimParam, PUCCH_DMRS_Ip,PUCCH_ZC_Data);

   //=======================Symbolic Level module Processing ============================//
  SRP_PUCCH_FE_fix(SimParam,BRP_UCI_Op,PUCCH_DMRS_Ip,PUCCH_ZC_Data,SubFrame_FD_Buffer);

  for (iSym = 0; iSym < PUCCH_DMRS_MAX_NUM; iSym++)
  {
	  free(PUCCH_DMRS_Ip[iSym]);
  }

  for (iSym = 0; iSym < PUCCH_DATA_MAX_NUM; iSym++)
  {
	  free(PUCCH_ZC_Data[iSym]);
  }
}

